﻿@inject IStringLocalizer<BootstrapBlazor.Shared.Samples.Menus> Localizer

<div style="height: 120px; position: relative;">
    <div>@ClickedMenuItemText</div>
    <Menu Items="@BottomItems" DisableNavigation="true" OnClick="@OnClickBottomMenu" IsBottom="true" />
</div>

@code {
    private string? ClickedMenuItemText { get; set; }

    [NotNull]
    private IEnumerable<MenuItem>? BottomItems { get; set; }

    private Task OnClickBottomMenu(MenuItem item)
    {
        ClickedMenuItemText = item.Text;
        StateHasChanged();
        return Task.CompletedTask;
    }

    /// <summary>
    /// OnInitialized 方法
    /// </summary>
    protected override async Task OnInitializedAsync()
    {
        await base.OnInitializedAsync();
        BottomItems = await MenusDataGerator.GetBottomMenuItemsAsync(Localizer);
    }
}
